const { fn } = require("jquery");
define(['jquery', 'bootstrap', 'backend', 'table','form2','jquery.validate','jquery.validate.lang'], function ($, undefined, Backend, Table, Form2){
    var Form3 = {
        config_investment: {
            fieldlisttpl: '<tr fieldlist-item="true"><td><input type="text" name="<%=name%>[investment_name][]" class="form-control"></td><td><select class="form-control investment_code" name="<%=name%>[investment_code][]">'+Config.area_option+'</select></td><td><div class="control-relative"><input class="form-control" data-toggle="city-picker" name="<%=name%>[investment_area][]" type="text"> </div></td><td><select id="investment_attribute_ids" multiple="1" class="form-control selectpicker" name="<%=name%>[investment_attribute_ids][<%=index%>][]" tabindex="-98">'+Config.attribute_option+'</select></td><td><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span></td><td></td></tr>'
        },
        config_contacts: {
            fieldlisttpl: '<tr fieldlist-item="true"><td><select id="assist_id" class="form-control valid" name="contacts[assist_id][]" aria-invalid="false">'+Config.assist_option+'</select></td><td><input type="text" name="contacts[assist_duty][]" class="form-control"></td><td><input type="text" name="contacts[assist_nickname][]" class="form-control"></td><td><input type="text" name="contacts[assist_tel][]" class="form-control"></td><td><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span></td><td></td></tr>'},
    };

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/index' + location.search,
                    del_url: 'project/del',
                    table: 'project',
                },
            });
            var table1 = $("#table1");
            // 初始化表格
            table1.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar1", 
                // pageSize: 'All', 
                showToggle:false,
                singleSelect:false,
                showExport:false,
                showColumns: false,
                // search:false,
                // height: 750, 
                // 启用固定列
                fixedColumns: true,
                //固定右侧列数
                fixedNumber: 4,
                queryParams: function (params) {
                    var op = JSON.parse(params.op);
                    op.settle_street_ids = "IN";
                    op.chargedep_ids = "IN";
                    op.assist_ids = "IN";
                    op.project_stage_id = "IN";
                    op.investment_attribute_ids = "IN";
                    op.carrier_id = "IN";
                    op.five_industry_id = "IN";
                    op.industry_realm_id = "IN";
                    op.industry_category_id = "IN";
                    op.leader_ids = "IN";
                    op.centraloffice_id = "IN";
                    op.asset_type_id = "IN";
                    op.project_source_ids = "IN";
                    op.progress_status_id = "IN";
                    params.op = JSON.stringify(op);
                    return params;
                },
                rowStyle:function(row,index){
                    var style = {};
                    var css = {};
                    if(Config.groupIds!=4)  //领导权限不标红
                    {
                       if(row.status == 0)
                            css.color = '#ff0000';
                        if(row.plan_time>0)
                        {
                            // 黄色背景
                            var timestamp = Date.parse(new Date());//当前时间
                            var end=row.plan_time*1000;//计划时间
                            var utc=end-timestamp;
                            var day = utc/(24*60*60*1000);// 天
                            if(day<10) //10天以内背景标黄
                            {
                                css.background = '#FFED97';
                                css.opacity = 0.8;
                            }  
                            // 红色背景
                            if(row.local_time>row.plan_time)
                            {
                                css.background = '#ff0000';
                                css.color = '#ffffff';
                                css.opacity = 0.8;
                            }
                        } 
                    }
                    
                    style.css = css;
                    return style;
                },
                columns:Controller.api.list_columns(table1),
            });
        
            // 为表格绑定事件
            Table.api.bindevent(table1);
            Controller.api.list_click(table1);
            Controller.api.bindevent();

            //当表格数据加载完成时
            table1.on('load-success.bs.table', function (e, data) {
                //这里可以获取从服务端获取的JSON数据
                // console.log(data.extend);
                $(".is_update_count").html(data.extend.update_total);
                $(".is_project_count").html(data.extend.total);
                $(".is_update_percent").html(data.extend.percent);

            });

            var table2 = $("#table2");
            // 初始化表格
            table2.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar2",
                queryParams:function(params){
                    // console.log(params);
                    params.filter = JSON.parse(params.filter);
                    params.op = JSON.parse(params.op);
                    params.filter.status = 0;
                    params.op.status = '=';
                    params.filter = JSON.stringify(params.filter);
                    params.op = JSON.stringify(params.op);
                    return params;
                },
                columns: Controller.api.check_columns(table2),
            });
            // 为表格绑定事件
            Table.api.bindevent(table2);
        },

        discuss: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/discuss' + location.search,
                    table: 'project',
                },
            });
            var table1 = $("#table1");

            // 初始化表格
            table1.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar1",    
                showToggle:false,
                singleSelect:false,
                showExport:false,
                showColumns: false,
                // search:false,
                // 启用固定列
                fixedColumns: true,
                //固定右侧列数
                fixedNumber: 4,
                queryParams: function (params) {
                    var op = JSON.parse(params.op);
                    op.settle_street_ids = "IN";
                    op.chargedep_ids = "IN";
                    op.assist_ids = "IN";
                    op.project_stage_id = "IN";
                    op.investment_attribute_ids = "IN";
                    op.carrier_id = "IN";
                    // op.socialized_department_id = "IN";
                    op.five_industry_id = "IN";
                    op.industry_realm_id = "IN";
                    op.industry_category_id = "IN";
                    // op.branch_leader_id = "IN";
                    op.leader_ids = "IN";
                    op.centraloffice_id = "IN";
                    op.asset_type_id = "IN";
                    op.project_source_ids = "IN";
                    op.progress_status_id = "IN";
                    params.op = JSON.stringify(op);
                    return params;
                },
                rowStyle:function(row,index){
                    var style = {};
                    var css = {};
                    if(Config.groupIds!=4)  //领导权限不标红
                    {
                       if(row.status == 0)
                            css.color = '#ff0000';
                        if(row.plan_time>0)
                        {
                            // 黄色背景
                            var timestamp = Date.parse(new Date());//当前时间
                            var end=row.plan_time*1000;//计划时间
                            var utc=end-timestamp;
                            var day = utc/(24*60*60*1000);// 天
                            if(day<10) //10天以内背景标黄
                            {
                                css.background = '#FFED97';
                                css.opacity = 0.8;
                            }  
                            // 红色背景
                            if(row.local_time>row.plan_time)
                            {
                                css.background = '#ff0000';
                                css.color = '#ffffff';
                                css.opacity = 0.8;
                            }
                        } 
                    }
                    style.css = css;
                    return style;
                },
                columns:Controller.api.list_columns(table1),
            });

            // 为表格绑定事件
            Table.api.bindevent(table1);
            Controller.api.list_click(table1);
            Controller.api.bindevent();
        },

        new_land: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/new_land' + location.search,
                    table: 'project',
                },
            });
            var table1 = $("#table1");

            // 初始化表格
            table1.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar1",    
                showToggle:false,
                singleSelect:false,
                showExport:false,
                showColumns: false,
                // search:false,
                // 启用固定列
                fixedColumns: true,
                //固定右侧列数
                fixedNumber: 4,
                queryParams: function (params) {
                    var op = JSON.parse(params.op);
                    op.settle_street_ids = "IN";
                    op.chargedep_ids = "IN";
                    op.assist_ids = "IN";
                    op.project_stage_id = "IN";
                    op.investment_attribute_ids = "IN";
                    op.carrier_id = "IN";
                    // op.socialized_department_id = "IN";
                    op.five_industry_id = "IN";
                    op.industry_realm_id = "IN";
                    op.industry_category_id = "IN";
                    // op.branch_leader_id = "IN";
                    op.leader_ids = "IN";
                    op.centraloffice_id = "IN";
                    op.asset_type_id = "IN";
                    op.project_source_ids = "IN";
                    op.progress_status_id = "IN";
                    params.op = JSON.stringify(op);
                    return params;
                },
                rowStyle:function(row,index){
                    var style = {};
                    var css = {};
                    if(Config.groupIds!=4)  //领导权限不标红
                    {
                       if(row.status == 0)
                            css.color = '#ff0000';
                        if(row.plan_time>0)
                        {
                            // 黄色背景
                            var timestamp = Date.parse(new Date());//当前时间
                            var end=row.plan_time*1000;//计划时间
                            var utc=end-timestamp;
                            var day = utc/(24*60*60*1000);// 天
                            if(day<10) //10天以内背景标黄
                            {
                                css.background = '#FFED97';
                                css.opacity = 0.8;
                            }  
                            // 红色背景
                            if(row.local_time>row.plan_time)
                            {
                                css.background = '#ff0000';
                                css.color = '#ffffff';
                                css.opacity = 0.8;
                            }
                        } 
                    }
                    
                    style.css = css;
                    return style;
                },
                columns:Controller.api.list_columns(table1),
            });
            // 为表格绑定事件
            Table.api.bindevent(table1);
            Controller.api.list_click(table1);
            Controller.api.bindevent();
        },

        centralcontact: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/centralcontact/leader/'+Config.leader+ location.search,
                    table: 'project',
                },
            });
            var table1 = $("#table1");

            // 初始化表格
            table1.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar1",    
                showToggle:false,
                singleSelect:false,
                showExport:false,
                showColumns: false,
                // search:false,
                // 启用固定列
                fixedColumns: true,
                //固定右侧列数
                fixedNumber: 4,
                queryParams: function (params) {
                    var op = JSON.parse(params.op);
                    op.settle_street_ids = "IN";
                    op.chargedep_ids = "IN";
                    op.assist_ids = "IN";
                    op.project_stage_id = "IN";
                    op.investment_attribute_ids = "IN";
                    op.carrier_id = "IN";
                    // op.socialized_department_id = "IN";
                    op.five_industry_id = "IN";
                    op.industry_realm_id = "IN";
                    op.industry_category_id = "IN";
                    // op.branch_leader_id = "IN";
                    op.leader_ids = "IN";
                    op.centraloffice_id = "IN";
                    op.asset_type_id = "IN";
                    op.project_source_ids = "IN";
                    op.progress_status_id = "IN";
                    params.op = JSON.stringify(op);
                    return params;
                },
                rowStyle:function(row,index){
                    var style = {};
                    var css = {};
                    if(Config.groupIds!=4)  //领导权限不标红
                    {
                       if(row.status == 0)
                            css.color = '#ff0000';
                        if(row.plan_time>0)
                        {
                            // 黄色背景
                            var timestamp = Date.parse(new Date());//当前时间
                            var end=row.plan_time*1000;//计划时间
                            var utc=end-timestamp;
                            var day = utc/(24*60*60*1000);// 天
                            if(day<10) //10天以内背景标黄
                            {
                                css.background = '#FFED97';
                                css.opacity = 0.8;
                            }  
                            // 红色背景
                            if(row.local_time>row.plan_time)
                            {
                                css.background = '#ff0000';
                                css.color = '#ffffff';
                                css.opacity = 0.8;
                            }
                        } 
                    }
                    
                    style.css = css;
                    return style;
                },
                columns:Controller.api.list_columns(table1),
            });
            // 为表格绑定事件
            Table.api.bindevent(table1);
            Controller.api.list_click(table1);
            Controller.api.bindevent();
        },

        signed: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project/signed/typeid/'+Config.typeid+ location.search,
                    table: 'project',
                },
            });
            var table1 = $("#table1");

            // 初始化表格
            table1.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                toolbar: "#toolbar1",    
                showToggle:false,
                singleSelect:false,
                showExport:false,
                showColumns: false,
                // 启用固定列
                fixedColumns: true,
                // search:false,
                //固定右侧列数
                fixedNumber: 4,
                queryParams: function (params) {
                    var op = JSON.parse(params.op);
                    op.settle_street_ids = "IN";
                    op.chargedep_ids = "IN";
                    op.assist_ids = "IN";
                    op.project_stage_id = "IN";
                    op.investment_attribute_ids = "IN";
                    op.carrier_id = "IN";
                    // op.socialized_department_id = "IN";
                    op.five_industry_id = "IN";
                    op.industry_realm_id = "IN";
                    op.industry_category_id = "IN";
                    // op.branch_leader_id = "IN";
                    op.leader_ids = "IN";
                    op.centraloffice_id = "IN";
                    op.asset_type_id = "IN";
                    op.project_source_ids = "IN";
                    op.progress_status_id = "IN";
                    params.op = JSON.stringify(op);
                    return params;
                },
                rowStyle:function(row,index){
                    var style = {};
                    var css = {};
                    if(Config.groupIds!=4)  //领导权限不标红
                    {
                       if(row.status == 0)
                            css.color = '#ff0000';
                        if(row.plan_time>0)
                        {
                            // 黄色背景
                            var timestamp = Date.parse(new Date());//当前时间
                            var end=row.plan_time*1000;//计划时间
                            var utc=end-timestamp;
                            var day = utc/(24*60*60*1000);// 天
                            if(day<10) //10天以内背景标黄
                            {
                                css.background = '#FFED97';
                                css.opacity = 0.8;
                            }  
                            // 红色背景
                            if(row.local_time>row.plan_time)
                            {
                                css.background = '#ff0000';
                                css.color = '#ffffff';
                                css.opacity = 0.8;
                            }
                        } 
                    }
                    
                    style.css = css;
                    return style;
                },
                columns:Controller.api.list_columns(table1),
            });
            // 为表格绑定事件
            Table.api.bindevent(table1);
            Controller.api.list_click(table1);
            Controller.api.bindevent();
        },
        addplan: function (){
            // 选择地址
            $('#plan_status').change(function(){
                var p1=$(this).children('option:selected').val();//selected的值
                if(p1==8)
                {
                    $(".plan_other").css("display","block");
                }else{
                    $(".plan_other").css("display","none");
                }
            });
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })
        },
        editplan: function (){
            $('#plan_status').change(function(){
                var p1=$(this).children('option:selected').val();//selected的值
                if(p1==8)
                {
                    $(".plan_other").css("display","block");
                }else{
                    $(".plan_other").css("display","none");
                }
            });

            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })            
        },
        addcentralcontact: function (){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })
        },
        editcentralcontact: function (){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })
        },
        viewcentralcontact:function () {
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
        },
        addstage_admin: function(){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        editstage_admin: function(){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        adddemo: function(){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                Form2.api.submit(form,function(){
                    parent.location.reload();
                });
            })  
        },
        addstage: function(){
            // 选择地址
            $('#project_stage_id').change(function(){
                var p1=$(this).children('option:selected').val();//selected的值
                // 修改选中默认的地址
                if(p1==6||p1==9||p1==10)
                {
                    if(p1==6){
                        $(".register_capital").show();
                        $(".register_name").show();
                        $(".reason").hide();
                    }else if(p1==9||p1==10){
                        $(".reason").show();
                        $(".register_capital").hide();
                        $(".register_name").hide();
                        $(".reason label").html('<span class="text-red">*</span>原因:')
                        $(".reason_res").attr("required",true)
                    }
                }else{
                    $(".register_capital,.register_name,.reason").hide();
                }
            });
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        editstage: function(){
            // 选择地址
            $('#project_stage_id').change(function(){
                var p1=$(this).children('option:selected').val();//selected的值
                // 修改选中默认的地址
                // alert(p1);
                if(p1==6||p1==9||p1==10)
                {
                    if(p1==6){
                        $(".register_capital").show();
                        $(".register_name").show();
                        $(".reason").hide();
                    }else if(p1==9||p1==10){
                        $(".reason").show();
                        $(".register_capital").hide();
                        $(".register_name").hide();
                        $(".reason label").html('<span class="text-red">*</span>原因:')
                        $(".reason_res").attr("required",true)
                    }
                    // $(".detail").show();
                }else{
                    $(".register_capital,.register_name,.reason").hide();
                }

            });
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        addprogress: function (){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        editprogress: function (){
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })  
        },
        export:function() {
            Controller.api.bindevent();
        },
        add: function () {
            Controller.api.wizard(0,'add');
            Controller.api.form(0);
            Controller.api.AddRecord(1);
        },
        
        update: function () 
        {
            Controller.api.AddRecord(2);

            $(".all_submit").click(function(event) {
                var that = this;
                Layer.confirm(__('确定要通过审核吗?'), {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "project/checkpass_all/ids/"+ Config.ids,
                        success: function (ret) {
                            Layer.alert(__('审核成功'), function(index){
                                location.reload();
                            });
                        },
                        error : function(error) {
                            console.log(error);
                        }
                    });
                    Layer.close(index);
                });
            });

            $(".btn-rejectmemo").click(function(event) {
                var that = this;
                var url = 'project/rejectmemo/ids/' + Config.ids;
                Fast.api.open(url, __('驳回备注'),  {});
            });
            Controller.api.UpdateRecord();
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                $(".project_typeid").val("0");
                if(!Config.isSuperAdmin){
                    form.validate().settings.ignore = "";
                }
                if(form.valid()){
                    Form2.api.submit(form);
                }
            })

            $(".btn-save").click(function(event){
                $(".project_typeid").val("1");
                Form2.api.submit(form);
            })
            $(".btn-confirm").click(function(event){
                $(".project_typeid").val("2");
                Form2.api.submit(form);
            })

        },
        checkedit: function () {
            Controller.api.bindevent();
            $(".all_submit").click(function(event) {
                var that = this;
                Layer.confirm(__('确定要通过审核吗?'), {
                    icon: 3,
                    title: '提示'
                }, function (index) {
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "project/checkpass_all/ids/"+ Config.ids,
                        success: function (ret) {
                            Layer.alert(__('提交成功'), function(index){
                                location.reload();
                            });
                        },
                        error : function(error) {
                            console.log(error);
                        }
                    });
                    Layer.close(index);
                });

            });

            $(".btn-rejectmemo").click(function(event) {
                var that = this;
                var url = 'project/rejectmemo/ids/' + Config.ids;
                Fast.api.open(url, __('驳回备注'),  {});
            });
        },
        rejectmemo:function() {
            var form = $("form[role=form]");
            Form2.api.bindevent(form);
            $(".btn-update").click(function(event){
                if(form.valid()){
                    Form2.api.submit(form,function(){
                        parent.location.reload();
                    });
                }
            })
        },
        api: {
            bindevent: function()
            {
                $(".control-label").hide();
                $(".form-group").css("margin-right","-140px");
                $(".status_custom").find("option").first().html("请选择状态");
                $(".contact_type_custom").find("option").first().html("请选择接洽类别");
                $(".country_custom").find("option").first().html("请选择投资方国别");
                Form2.api.bindevent($("form[role=form]"));
            },
            AddRecord: function (x){
                if(x==1)
                {
                    $('.name').blur(function(){
                       var value = $(this).val();
                       if(value)
                       {
                        $.ajax({
                            url: 'project/ajaxproject',
                            data: {name:value},
                            type: 'post',
                            dataType: 'json',
                            success: function (data, textStatus, xhr) {
                                if(data.code==1){
                                    Layer.alert(__('项目已存在'));
                                }
                                // $(".name").focus();

                            },
                            error: function (xhr, textStatus, error) {
                            }
                        });                    
                       }
                    });
                }

                $('#carrier_id').change(function(event) {
                    var value = $(this).val();
                    var id = $(this).attr('id');

                    var unit = '';
                    var readonly = false;
                    var required = null;
                    switch (value) {
                        case "1":
                        case "6":
                            unit = "亩";
                            readonly = false;
                            required = "required";
                            break;
                        case "2":
                        case "3":
                        case "4":
                            unit = "平米";
                            readonly = false;
                            required = "required";
                            break;
                        case "5":
                            unit = "";
                            readonly = true;
                            required = null;
                            break;
                    }
                    $("#carrier_id_relation").attr('readonly', readonly);
                    if(!Config.isSuperAdmin){
                        $("#carrier_id_relation").attr('required',required);
                    }
                    $("#carrier_id_addon").html(unit);
                });
                
                $('.industry_realm_id').change(function(event) {
                    var value = $(this).val();
                    if(value==14) {
                        $(".industry_realm_other").show();
                        $(".industry_realm_other").attr('required', true);
                        // $(".industry_realm_other").css('display','block');
                        $(".industry_realm_id").css('width','49%');
                        $(".industry_realm_id").css('float','left');
                    }else{
                        $(".industry_realm_other").hide();
                        $(".industry_realm_id").css('width','100%');
                        $(".industry_realm_id").css('float','');
                        $(".industry_realm_other").val('');
                        $(".industry_realm_other").attr('required', false);
                        // $(".industry_realm_other").css('display','none');
                    }
                        
                });

                $('.five_industry_id').change(function(event) {
                    var value = $(this).val();
                    if(value==6) {
                        $(".five_industry_other").show();
                        if(!Config.isSuperAdmin){
                            $(".five_industry_other").attr('required', true);
                        }
                        $(".five_industry_id").css('width','49%');
                        $(".five_industry_id").css('float','left');
                    }else{
                        $(".five_industry_other").hide();
                        if(!Config.isSuperAdmin){
                            $(".five_industry_other").attr('required', false);
                        }
                        $(".five_industry_id").css('width','100%');
                        $(".five_industry_id").css('float','');
                        $(".five_industry_other").val('');
                    }
                        
                });

                // 区领导 选择市领导
                $('.is_recommend_arealeader').change(function(event) {
                    var value = $(this).val();
                    if(value=='是')
                    {
                        $(".cityleader").css('display', 'block');
                        $(".arealeader_reason").css('display', 'none');
                        if(!Config.isSuperAdmin)
                            $(".is_recommend_cityleader").attr('required', true);
                    }else if(value=='否'){
                        // 显示理由
                        $(".cityleader").css('display', 'none');
                        $(".arealeader_reason").css('display', 'block');
                        $(".cityleader_reason").css('display', 'none');
                    }else{
                        $(".cityleader").css('display', 'none');
                        $(".arealeader_reason").css('display', 'none');
                        $(".cityleader_reason").css('display', 'none');

                        $(".is_recommend_cityleader").attr('required', false);
                    }
                });

                $('.is_recommend_cityleader').change(function(event) {
                    var value = $(this).val();
                    if(value=='否')
                        $(".cityleader_reason").css('display', 'block');
                    else
                        $(".cityleader_reason").css('display', 'none');
                });

                //追加控制
                //
                $(".fieldlist").on("click", ".btn-new", function (e, row) {
                    
                    var item = $(this).parents("tbody").attr('list_length');
                    item = item-1;
                    var container = $(this).closest(".fieldlist");
                    var tagName = container.data("tag") || "tr";
                    var index = container.data("index");
                    var name = container.data("name");
                    var template = container.data("template");
                    var data = container.data();
                    if(x==1)
                        index = index ? parseInt(index) : 1;
                    if(x==2)
                        index = index ? parseInt(index) : item+1;

                    container.data("index", index + 1);
                    row = row ? row : {};
                    var vars = {index: index, name: name, data: data, row: row};
                    var html = template ? Template(template, vars) : Template.render(Form3.config_investment.fieldlisttpl, vars);
                    $(html).insertAfter($(tagName + ":last", container));
                    $(this).trigger("fa.event.appendfieldlist", $(this).closest(tagName).prev());

                    // 绑定选择
                    require(['bootstrap-select', 'bootstrap-select-lang'], function () {
                        $('.selectpicker').selectpicker();
                    });
                    // 绑定地区
                    require(['citypicker'], function () {
                        $("[data-toggle='city-picker']").citypicker('refresh');
                    });
                });

                $(document).on("change", ".investment_code", function () {
                    var value = $(this).val();
                    if(value!='CN')
                    {
                        $(this).parent("td").next().children(".control-relative").children(".city-picker-span").hide();
                    }else
                        $(this).parent("td").next().children(".control-relative").children(".city-picker-span").show();
                });

                //移除追加
                $(".fieldlist").on("click", ".btn-remove", function () {
                    var container = $(this).closest(".fieldlist");
                    var tagName = container.data("tag") || "tr";
                    $(this).closest(tagName).remove();
                    refresh(container.data("name"));
                });

                $(".fieldlist").on("click", ".btn-make", function (e, row) {
                    var container = $(this).closest(".fieldlist");
                    var tagName = container.data("tag") || "tr";
                    var index = container.data("index");
                    var name = container.data("name");
                    var template = container.data("template");
                    var data = container.data();
                    index = index ? parseInt(index) : 0;
                    container.data("index", index + 1);
                    row = row ? row : {};
                    var vars = {index: index, name: name, data: data, row: row};
                    var html = template ? Template(template, vars) : Template.render(Form3.config_contacts.fieldlisttpl, vars);
                    $(html).insertAfter($(tagName + ":last", container));
                    $(this).trigger("fa.event.appendfieldlist", $(this).closest(tagName).prev());
                });

                // 选择项目来源
                $('#project_source_year').change(function(){
                    var source_year =$(this).children('option:selected').val();//selected的值
                    
                    $(".source_id").css("display","block");
                    $.ajax({
                        url: 'project/ajaxactivity',
                        data: {source_year:source_year},
                        type: 'post',
                        dataType: 'json',
                        success: function (data, textStatus, xhr) {
                            if(data.code==1)
                                $("#project_source_ids").html(data.msg)
                        },
                        error: function (xhr, textStatus, error) {
                        }
                    });
                });

                
            },

            UpdateRecord:function()
            {
                // 新增阶段
                $(".btn-addstage").click(function(event) {
                    var that = $(this).attr("data");
                    var url ='project/addstage/ids/'+ Config.ids;
                    Fast.api.open(url, '新增', {area:['50%','65%']})
                })

                $(".btn-view").click(function(event){
                    var that = $(this).attr("ids");
                    var url ='project/viewstage/ids/'+ that;
                    Fast.api.open(url, '详情', {area:['50%','65%']})
                });

                // 新增阶段
                $(".btn-addprogress").click(function(event) {
                    var that = $(this).attr("data");
                    var url ='project/addprogress/ids/'+ Config.ids;
                    Fast.api.open(url, '新增', {area:['50%','75%']})
                })

                $(".btn-detail").click(function(event){
                    var that = $(this).attr("ids");
                    var url ='project/viewprogress/ids/'+ that;
                    Fast.api.open(url, '详情', {area:['50%','75%']})
                });


                // 新增计划
                $(".btn-addplan").click(function(event) {
                    var that = $(this).attr("data");
                    var url ='project/addplan/ids/'+ Config.ids;
                    Fast.api.open(url, '新增', {area:['65%','65%']})
                })

                // 编辑计划
                $(".btn-amend").click(function(event) {
                    var that = $(this).attr("ids");
                    var edit = $(this).attr("edit");

                    if (edit=='stage')
                        var url ='project/editstage/ids/'+ that;
                    else if(edit=='progress')
                        var url ='project/editprogress/ids/'+ that;
                    else if(edit=='centralcontact')
                        var url ='project/editcentralcontact/ids/'+ that;
                    else
                        var url ='project/editplan/ids/'+ that;

                    Fast.api.open(url, '编辑', {area:['65%','65%']})
                })

                // 是否达标
                $(".btn-stand").click(function(event) {
                    var that = $(this).attr("ids");
                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url: "project/stand/ids/"+ that,
                        success: function (ret) {
                            Layer.alert(__('已达标'), function(index){
                                location.reload();
                            });
                        },
                        error : function(error) {
                            console.log(error);
                        }
                    }); 
                })

                // 删除计划
                $(".btn-delete").click(function(event) {
                    var that = $(this).attr("ids");
                    var del = $(this).attr("del");

                    if (del=='stage')
                        var url = "project/delstage/ids/"+ that;
                    else if(del=='progress')
                        var url = "project/delprogress/ids/"+ that;
                    else if(del=='centralcontact')
                        var url = "project/delcentralcontact/ids/"+ that;
                    else
                        var url = "project/delplan/ids/"+ that;

                    $.ajax({
                        //几个参数需要注意一下
                        type: "POST",//方法类型
                        dataType: "json",//预期服务器返回的数据类型
                        url:url,
                        success: function (ret) {
                            Layer.alert(__('删除成功'), function(index){
                                location.reload();
                            });
                        },
                        error : function(error) {
                            console.log(error);
                        }
                    }); 
                })

                // 新增接洽信息
                $(".btn-addcentralcontact").click(function(event) {
                    var that = $(this).attr("data");
                    var url ='project/addcentralcontact/ids/'+ Config.ids;
                    Fast.api.open(url, '新增', {area:['55%','85%']})
                });

                // 接洽信息详情
                $(".btn-detailcontact").click(function(event){
                    var that = $(this).attr("ids");
                    var url ='project/viewcentralcontact/ids/'+ that;
                    Fast.api.open(url, '详情', {area:['55%','85%']})
                });

                // 管理员新增项目当前阶段
                $(".btn-insert").click(function(event) {
                    // var that = $(this).attr("data");
                    var url ='project/addstage_admin/ids/'+ Config.ids;
                    Fast.api.open(url, '添加', {area:['50%','65%']})
                })
                // 编辑项目当前阶段
                $(".btn-editor").click(function(event) {
                    var url ='project/editstage_admin/ids/'+ Config.ids;
                    Fast.api.open(url, '编辑', {area:['50%','65%']})
                })

                $(".btn-demo").click(function(event) {
                    // var that = $(this).attr("data");
                    var url ='project/adddemo/ids/'+ Config.ids;
                    Fast.api.open(url, '添加', {area:['50%','65%']})
                })
                $(".btn-editdemo").click(function(event) {
                    var url ='project/adddemo/ids/'+ Config.ids;
                    Fast.api.open(url, '编辑', {area:['50%','65%']})
                })

                // 查看记录
                $(".all_modidy_detail").click(function(event) {
                    var that = $(this).attr("data");
                    var url ='project_check/fieldlog?project_id='+ Config.ids+ '&field='+that;
                    Fast.api.open(url, '', {area:['95%','95%']})
                })

            },
            form: function(){
                Form2.api.bindevent($("form[role=form]"));
            },
            custom: function() {
                var form = $("form[role=form]");
                var events = Form2.events;
                events.datetimepicker(form);
                events.plupload(form);
            },
            wizard: function(type,formaction){
                var ids = Config.ids;
                var bot_tip = '';
                var finish_label = '提交审核';
                var disabledFinishButton = true;
                var status = Config.status;
                
                var form2 = $("form[role=form]").show();

                var startIndex = 0;
                if(type ==1)
                    startIndex = 1; 
                form2.children("div").steps({
                    labels: {
                        next: '下一步',
                        previous : '上一步',
                        finish: finish_label,
                        custom: '暂存',
                    },
                    startIndex: startIndex,
                    enableCustomButton: true,
                    showCustomArr:[0,2],
                    disabledFinishButton: disabledFinishButton,
                    headerTag: "h2",
                    bodyTag: "section",
                    botTip: bot_tip,
                    onStepChanging: function (event, currentIndex, newIndex)
                    {
                        var project_id = $(".project_id").val();
                        // alert(currentIndex+'项目id:'+project_id);
                        if(currentIndex != 2)
                        {
                           
                            form2.validate().settings.ignore = ":disabled,:hidden";
                            var bool_submit = false;
                            if(form2.valid()){
                                bool_submit = Controller.api.formsubmit(status,project_id,currentIndex);
                                if(bool_submit)
                                    return true;
                                else
                                    return false;  
                            }
                        }
                        else
                            return true;
                                                 
                    },
                    onFinishing: function (event, currentIndex)
                    {
                        var project_id = $(".project_id").val();
                        
                            form2.validate().settings.ignore = "";
                            var bool_submit = false;
                            if(form2.valid() ){
                               bool_submit = Controller.api.formsubmit(status,project_id,currentIndex);
                                if(bool_submit)
                                {
                                    return true;
                                }
                                else
                                    return false;
                            }
                            else
                                return false;
                        
                    },
                    onFinished: function (event, currentIndex)
                    {
                        Layer.alert(__('保存成功'), function(index){
                            // window.location.href="../../../project/index";
                           location.reload();
                        });
                    },
                    // 暂存
                    onCustom:function(event, currentIndex) {
                        var name = $(".name").val();
                        if(name=="")
                        {
                            Layer.alert(__('项目名称不能为空'));
                            return false;
                        }
                        var chargedep_ids = $(".chargedep_ids").val();
                        if(chargedep_ids=="")
                        {
                            Layer.alert(__('主责部门不能为空'));
                            return false;
                        }
                        var res = Controller.api.formsubmit(status);
                        if(res)
                            alert('保存成功');
                    }
                });
            },
            formsubmit: function(status,project_id,currentIndex) {
                var form2 = $("form[role=form]").show();
                url = form2.attr("action");
                url = url ? url : location.href;
                var bool_submit = false;
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: url ,//url
                    data: form2.serialize()+ "&row[status]=" + status + '&project_id='+project_id+'&current='+currentIndex,
                    async: false,
                    success: function (ret) {
                        if(ret.code == 1)
                        {
                            $(".project_id").val(ret.msg);
                            bool_submit = 1;
                        }
                    },
                    error : function(error){
                        Layer.alert(ret.msg);
                        return false;
                    }
                });
                return bool_submit;
            },
           
            check_columns: function(table){
                var field_columns =[
                    {checkbox: true},
                    {field: 'id', title: __('Id'),operate:false},
                    {field: 'name', title: __('Name')},
                    {field: 'chargedep_names', title: __('提报部门')},
                    {
                        field: 'check',
                        width: "120px",
                        title: __('审核'),
                        table: table,
                        events: Table.api.events.operate,
                        visible: Config.isSuperAdmin ? true:false,
                        operate:false,
                        buttons: [
                            {
                                name: 'check',
                                text: '审核',
                                title: __('审核'),
                                classname: 'btn btn-xs btn-warning  btn-magic btn-addtabs',
                                icon: 'fa fa-folder-o',
                                url: 'project/checkedit',
                            }
                        ],
                        formatter: function (value, row, index) {
                            if(Config.isSuperAdmin){
                                return Table.api.formatter.buttons.call(this, value, row, index);
                            }
                            return '';
                        }
                    }

                ];
                return [field_columns];
            },//end check_colums

            list_columns: function(table){
                var field_columns =[
                    {checkbox: true},
                    {field: '', title: __('序号'), operate:false,table: table,width:'60px',formatter:Table.api.formatter.natureorder},
                    {field: 'status',title:'状态',operate:false,width:'100px',visible:Config.groupIds!=4?true:false,
                        formatter: function (value,row,index) {
                            if(value == -1) {
                                return '<a href="javascript:;" class="btn btn-info">待提交</a>';
                            }else if(value == 0){
                                return '<a href="project/checkedit/ids/' + row.id + '" class="btn btn-primary btn-addtabs">待审核</a>';
                            }else if(value == 1){
                                return '<a href="javascript:;" class="btn btn-success">已更新</a>';
                            }else if(value == 2){
                                return '<a href="javascript:;" class="btn btn btn-danger">已驳回</a>';
                            }else{
                                return '<a href="javascript:;" class="btn btn btn-warning">未更新</a>';
                            }
                        }
                    },
                    {field: 'name', title: __('项目名称'),operate:'like',align:'left',haign:'center',placeholder: '项目名称',
                        formatter:function(value,row,index){
                            if(row.name&&row.name.length<=16){
                                return '<div title="'+row.name+'" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.name+'</div>';
                            }
                            if(row.name&&row.name.length>16){
                              return '<div title="'+row.name+'" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.name.substring(0,16)+'...</div>';
                            }
                        }
                    },
                    {field: 'chargedep_names', title: __('主责部门'),operate:false,align:'left',width:'100px',
                        formatter:function(value,row,index){
                            if(row.chargedep_names&&row.chargedep_names.length<=10){
                                return '<div title="'+row.chargedep_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.chargedep_names+'</div>';
                            }
                            if(row.chargedep_names&&row.chargedep_names.length>10){
                              return '<div title="'+row.chargedep_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.chargedep_names.substring(0,10)+'...</div>';
                            }
                        }
                    },
                    {field: 'chargedep_ids', title: __(''),visible:false,placeholder: '主责部门',addClass: 'selectpage',extend: "data-source='chargedep/street' data-multiple='true'", operate:'IN',},
                    {field: 'assist_ids', title: __(''),visible:false,placeholder: '协办部门',addClass: 'selectpage',
                        extend: "data-source='chargedep/street' data-multiple='true'"},
                    // {field: 'assist_names',title:'协办部门',operate:false,align:'left',width:'100px',
                    //     formatter:function(value,row,index){
                    //         if(row.assist_names&&row.assist_names.length<=10){
                    //             return '<div title="'+row.assist_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.assist_names+'</div>';
                    //         }
                    //         if(row.assist_names&&row.assist_names.length>10){
                    //           return '<div title="'+row.assist_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.assist_names.substring(0,10)+'...</div>';
                    //         }
                    //     }
                    // },
                    {field: 'investment_name', title: __('投资方名称'),align:'left',width:'100px',operate:'like',placeholder: '投资方名称',haxextra:true,
                        formatter:function(value,row,index){
                            if(row.investment_name&&row.investment_name.length<=10){
                                return '<div title="'+row.investment_name+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.investment_name+'</div>';
                            }
                            if(row.investment_name&&row.investment_name.length>10){
                              return '<div title="'+row.investment_name+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.investment_name.substring(0,10)+'...</div>';
                            }
                        }
                    },
                    {field: 'investment_area', title: __('投资方地区'),align:'left',width:'100px',placeholder: '投资方地区',operate:'like',haxextra:true,
                        formatter:function(value,row,index){
                            if(row.investment_area&&row.investment_area.length<=10){
                                return '<div title="'+row.investment_area+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.investment_area+'</div>';
                            }
                            if(row.investment_area&&row.investment_area.length>10){
                              return '<div title="'+row.investment_area+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.investment_area.substring(0,10)+'...</div>';
                            }
                        }
                    },
                    {field: 'investment_country', title: __(''),visible:false,placeholder:'投资方国别',addclass:'country_custom',haxextra:true,searchList: Config.different_countries},
                    {field: 'investment_attribute_ids', title: __(''),placeholder:'投资方性质',visible:false,haxextra:true,addClass: 'selectpage',extend: "data-source='investor/index' data-multiple='true'"},
                    {field: 'investment_total', title: __('Investment_total'),operate:'BETWEEN',width:'100px',placeholder:__('Investment_total')},
                    {field: 'asset_type_id', title: __(''),placeholder: '投资类别',visible:false,addClass: 'selectpage',
                        extend: "data-source='type/index' data-multiple='true'",},
                    {field: 'asset_type_name', title: __('投资类别'),operate:false,width:'100px',},
                    {field: 'project_source_ids', title: __(''),placeholder:'项目类别',visible:false,haxextra:true,addClass: 'selectpage',
                        extend: "data-source='activity/index' data-multiple='true' data-order-by='weigh desc'",},
                    {field: 'project_source_names', title: __('项目类别'),operate:false,width:'150px',
                        formatter:function(value,row,index){
                            if(row.project_source_names&&row.project_source_names.length<=10){
                                return '<div title="'+row.project_source_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.project_source_names+'</div>';
                            }
                            if(row.project_source_names&&row.project_source_names.length>10){
                              return '<div title="'+row.project_source_names+'" style="width:100px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+row.project_source_names.substring(0,10)+'...</div>';
                            }
                        }
                    },
                    {field: 'branch_leader_id', title: __(''),visible:false,placeholder:'分管区领导',operate:false},
                    {field: 'industry_category_id', title: __(''),placeholder: '产业类别',visible:false,addClass: 'selectpage',
                        extend: "data-source='industry_category/index' data-multiple='true'",},
                    {field: 'industry_realm_id', title: __(''),visible:false,placeholder:'产业领域（十强）',addClass: 'selectpage',
                        extend: "data-source='realm/index' data-multiple='true'",},
                    {field: 'five_industry_id', title: __(''),visible:false,placeholder:'五大产业',addClass: 'selectpage',
                        extend: "data-source='five_industry/index' data-multiple='true'",},
                        
                    {field: 'trade_category_ids', title: __(''),visible:false,placeholder:'行业类别',addClass: 'selectpage',
                        extend: "data-source='trade_category/index' data-multiple='true'",haxextra:true,},

                    {field: 'settle_street_ids', title: __(''),visible:false,placeholder:'落户街道',
                        addClass: 'selectpage',
                        extend: "data-source='chargedep/street' data-multiple='true'"},
                    {field: 'carrier_id', title: __(''),visible:false,placeholder:'载体情况',addClass: 'selectpage',
                        extend: "data-source='carrier/index' data-multiple='true'"},
                    {field: 'carrier_id_relation', title: __(''),visible:false,operate:'like',placeholder:'载体面积'},
                    {field: 'leader_ids', title: __(''),visible:false,haxextra:true,placeholder:'区领导接洽',addClass: 'selectpage',
                        extend: "data-source='contact_leader/index' data-multiple='true' data-order-by='id asc'",},

                    {field: 'centraloffice_id', title: __(''),visible:false,haxextra:true,placeholder:'接洽科室',addClass: 'selectpage',
                        extend: "data-source='centraloffice/index' data-multiple='true' data-order-by='weigh desc'",},
                    {field: 'receive_time', title: __(''), placeholder:'接洽时间',
                        width:'100px',visible:false,operate:'RANGE',haxextra:true, 
                        addclass:'datetimerange_custom', 
                        formatter:Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'
                    },
                    {field: 'project_stage_id', title: __(''),
                        visible:false,haxextra:true,placeholder:'项目阶段(在谈请单独查询)',
                        operate:'FIND_IN_SET',
                        addClass: 'selectpage',
                        extend: "data-source='progress/index' data-multiple='true'",
                    },
                    {field: 'progress_status_id', title: __(''),visible:false,placeholder:'项目当前阶段',
                        addClass: 'selectpage',
                        extend: "data-source='progress/index' data-multiple='true'",
                    },
                    {field: 'progress_status_name', title: __('项目当前阶段'),operate:false,width:'100px'},
                    {field: 'progress_status_time', title: __('更新时间'), 
                        width:'100px',operate:false,haxextra:true, 
                        addclass:'datetimerange', formatter:Table.api.formatter.datetime,
                        datetimeFormat:'YYYY-MM-DD'
                    },
                    {field: 'project_stage_time', title: __(''), placeholder:'项目阶段时间',
                        width:'100px',visible:false,operate:'RANGE',haxextra:true, 
                        addclass:'datetimerange_custom', 
                        formatter:Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'
                    },
                    {field:'progress_statusid',title: __(''),visible:false,operate:Config.is_stop==1?'=':false,haxextra:true,defaultValue:"2",searchList: {"1": __('显示暂缓/终止'), "2": __('不显示暂缓/终止')}},
                    {field:'is_recommend_arealeader',title: __(''),visible:false,searchList: {"是": __('推荐区领导走访'), "否": __('不推荐区领导走访')}},
                    {field:'is_recommend_cityleader',title: __(''),visible:false,searchList: {"是": __('推荐市领导走访'), "否": __('不推荐市领导走访')}},
                    {field:'status',title: __(''),visible:false,addclass:'status_custom',searchList: {"-1": __('待提交'), "0": __('待审核'), "1": __('已更新'), "2": __('已驳回'), "3": __('未更新')}},
                    {field:'contact_typeid',title: __(''),visible:false,haxextra:true,addclass:'contact_type_custom',searchList: {"1": __('外出考察'),  "2": __('在青会见')}},
                    {field: 'operate', title: __('Operate'),width:'100px', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                ];
                return [field_columns];
            }, //end list_columns

            list_click:function(table)
            {
                var parenttable = table.closest('.bootstrap-table');
                var options = table.bootstrapTable('getOptions');
                var toolbar = $(options.toolbar, parenttable);
                
                // 详情
                $(toolbar).on('click', ".btn-detail", function () {
                    var that = this;
                    //循环弹出多个编辑框
                    $.each(table.bootstrapTable('getSelections'), function (index, row) {
                        var url = 'project/detail';
                        row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
                        var url = Table.api.replaceurl(url, row, table);
                        var icon = 'fa fa-info';
                        Backend.api.addtabs(url, '详情-'+row.name, icon);
                    });
                });

                // 编辑
                $(toolbar).on('click', ".btn-update", function () {
                    var that = this;
                    //循环弹出多个编辑框
                    $.each(table.bootstrapTable('getSelections'), function (index, row) {
                        var url = 'project/update/ids/'+row.id;
                        var icon = 'fa fa-pencil';
                        Backend.api.addtabs(url, '编辑', icon);
                    });
                });

                // 添加
                $(toolbar).on('click', ".btn-create", function () {
                    var url = 'project/add';
                    var icon = 'fa fa-plus';
                    Backend.api.addtabs(url, '添加', icon);
                });

                // 导出
                $(toolbar).on('click', ".btn-export", function (){
                    var search = options.queryParams({});
                    var filter = JSON.parse(search.filter);
                    var filterextra = JSON.parse(search.filterextra);
                    var op = JSON.parse(search.op);
                    var data_index = $(this).attr("data");
                    if(data_index=='index'|| data_index=='discuss'||data_index=='new_land'){
                        if(data_index=='index'){
                            url = 'project/export';
                        }
                        else if(data_index=='discuss'){
                            url = 'export_discuss';
                        }else{
                            url = 'export_new_land';
                        }

                        if(url)
                            location.href= url + '?filter='+JSON.stringify(filter)+'&op='+JSON.stringify(op)+'&filterextra='+JSON.stringify(filterextra);
                    }else if(data_index=='signed'||data_index=='centralcontact'){
                        if(data_index=='signed'){
                            url = 'project/export_signed/typeid/'+Config.typeid;
                        }else{
                            url = 'project/export_centralcontact/leader/'+Config.leader;    
                        }
                        // url = 'project/export_signed/typeid/'+Config.typeid+'/leader/'+Config.leader;
                        Backend.api.addtabs(url, '', ''); 
                        // if(url)
                        //     location.href= url + '?filter='+JSON.stringify(filter)+'&op='+JSON.stringify(op)+'&filterextra='+JSON.stringify(filterextra);
                    }
                });
            },
        }
    };
    return Controller;
});